package net.mymilkedeek.ludum.tinythumb.states;

import net.mymilkedeek.ludum.tinythumb.Game;
import org.newdawn.slick.*;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

/**
 * TODO: Write Documentation
 *
 * @author Michael Demey
 */
public class BadState extends BasicGameState {
    @Override
    public int getID() {
        return Game.S_BAD;
    }
    
    private Image bg;
    private int count = 0;

    @Override
    public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException {
        
        bg = new Image("/resources/spritesheets/bad.png");
    }

    @Override
    public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException {
        graphics.setColor(Color.white);
        switch ( count ) {
            case 4:
                bg.draw(0,0);
                break;
            case 3:
                graphics.drawString("Sorry.", 20, 200);
            case 2:
                graphics.drawString("\"We're sorry\" they said.", 20, 150);
            case 1:
                graphics.drawString("The doctors said they couldn't wait.", 20, 100);
            case 0:
                graphics.drawString("Unfortunately, you came too late.", 20, 50);
                break;
        }
    }

    @Override
    public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException {
        if ( gameContainer.getInput().isKeyPressed(Input.KEY_SPACE)) {
            if ( count < 4 ) {
                count++;
            } else if ( count >= 4 ) {
                gameContainer.reinit();
            }
        }
    }
}
